home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3468 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  55 lines

  1. Path: fang.dsto.defence.gov.au!mrd186
  2. From: yenh@MRD.SRL.dsto.gov.au (Hung Yen)
  3. Newsgroups: comp.lang.c
  4. Subject: Please help!
  5. Date: Mon, 29 Jan 96 23:14:54 GMT
  6. Organization: Ericsson Defence Systems
  7. Distribution: world
  8. Message-ID: <4ehtt2$313@fang.dsto.defence.gov.au>
  9. NNTP-Posting-Host: mrd186.dsto.gov.au
  10. X-Newsreader: News Xpress Version 1.0 Beta #2
  11.  
  12. Please take a look at this source code:
  13.  
  14. #include <Xm/List.h>
  15. #include <stdio.h>
  16. /* Function to sort an array of integers into ascending order */
  17. void sort (a,n)
  18. int a[];
  19. int n;
  20. {
  21.   int i,j,temp;
  22.   for (i=0; i < n -1; ++i)
  23.     for (j=i+1; j<n; ++j)
  24.       if (a[i] > a[j])
  25.         {
  26.            temp = a[i];
  27.            a[i] = a[j];
  28.            a[j] = temp;
  29.          }
  30.  
  31. }
  32.  
  33. int get_first_selected_plans(w,selected_count)
  34. Widget w;
  35. int selected_count;
  36. {
  37.   int **position_list;
  38.   int *position_count, first_selected_plan_number;
  39.   Boolean Ok;
  40.  
  41.   if (!w){
  42.     return 0;
  43.   }
  44.   Ok = XmListGetSelectedPos(w,position_list,position_count);
  45.   sort(position_list,&position_count);
  46.   first_selected_plan_number = position_list[1];
  47.   return first_selected_plan_number;
  48. }
  49.  
  50. This is my first try at C programming, so any help will be greatly appreciate.
  51.  
  52. hung
  53.  
  54.  
  55.